home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / util / Mac F2C 1.3.sit / Mac F2C 1.3 / Mac F2C v1.3 Documentation.rsrc / TEXT_137.txt < prev    next >
Text File  |  1995-12-11  |  10KB  |  123 lines

  1. Using Mac F2C With Symantec C/C++ for PPC
  2.  
  3. Before you can use the code produced by Mac F2C, you must set up and build all of the required support libraries.  There are also special rules that must be followed when using code produced by Mac F2C.  The process and rules are slightly different for each compiler.  These instructions are for setting up Mac F2C for use with Symantec C/C++ for PPC.  Refer to other chapters for instructions on how to set things up for use with THINK C/C++ for 68K or Metrowerk‚Äôs CodeWarrior C/C++ compilers.
  4.  
  5. Users upgrading from earlier versions need to re-install all libraries, project files, and supporting files.  All files, including library source code, have been updated in version 1.3.    
  6.  
  7. All of the Symantec project files shipped with Mac F2C are for the Symantec Project Manager (SPM) version 8.0.3 (the version included with Release 4 of Symantec C++ for Power Mac v8).  They cannot be opened by SPM v8.0.  If you have v8.0, I (and Symantec) urge you to upgrade to 8.0.3 using the free updaters available at major archive sites.
  8.  
  9. Project files for SPM version 8.0.4 are included in the SPM Support folder in a folder called SPM 8.0.4 Project Files.  If you replace all the SPM 8.0.3 project files distributed with Mac F2C with the corresponding ones appearing in the SPM 8.0.4 Project Files folder, you can then use the installer application to install Mac F2C for SPM 8.0.4.  Please note that the v8.0.4 installation has been tested only against the pre-release 8.0.4d11 version of the SPM.  There may be some differences between this pre-release version and the final 8.0.4 version of SPM.  These potential changes could break either the installer application or the project files themselves.  Use the 8.0.4 project files at your own risk.  If required, I will release an update to Mac F2C once the final SPM 8.0.4 is released.
  10.  
  11.  
  12. Setting Up Mac F2C Using the Installer
  13.  
  14. The easiest way to set up Mac F2C is to use the installer included with Mac F2C.  This installer will only work correctly if you have System 7.5 (or higher) and have Symantec v8.  If you do not meet both of these requirements, please follow the instructions for manual installation found in the following section.
  15.  
  16. The installer is stand-alone AppleScript application called Mac F2C Installer.  To run the installer, simply double click on it, and answer the dialogs it presents.  The installer will do the following:
  17.  
  18. ‚Ä¢ Create a folder called Mac F2C Support within the folder containing the Symantec Project Manager.
  19. ‚Ä¢ Build the appropriate Mac F2C libraries.
  20. ‚Ä¢ Move the built libraries to the Mac F2C Support folder.
  21. ‚Ä¢ Copy the Mac F2C project models to Symantec‚Äôs (Project Models) folder.
  22. ‚Ä¢ Translate and build the appropriate versions of the test application.
  23.  
  24. When the installer is finished, you will find completed test applications in the Test Project Δí folder.  You should run these to verify correct operation of Mac F2C and its libraries.  After that, you are ready to go.  To compile translated FORTRAN code, simply open a new project in the Symantec Project Manager, select the appropriate version of Mac F2C project models, and add the translated files.
  25.  
  26. The remaining sections provide step-by-step instructions for installing Mac F2C manually, a more detailed description of how to test your Mac F2C installation, and additional information on using code generated by Mac F2C with Symantec Project Manager.
  27.  
  28.  
  29. Setting Up Mac F2C Manually
  30.  
  31. Set up is a two step process.  First you must build the libraries, and then you must move several files to their proper locations.
  32.  
  33. Step 1:  Build all the libraries
  34.  
  35. The libraries of the Mac F2C distribution come without binaries, so you have to build them according to the following algorithm:
  36.  
  37. FOR the project files in the Mac F2C Libraries folder:
  38.     (1) libI77 PPC
  39.     (2) libF77 PPC
  40. REPEAT the following steps:
  41.     (a) Double-click on the project file.  
  42.     (b) In the Symantec Project Manager‚Äôs Build menu, 
  43.          select the Build Library command.  
  44.     (c) When finished, select the Remove Objects 
  45.          command in the Build menu.  
  46. END REPEAT
  47.  
  48. Step 2:  Move things to the recommended locations
  49.  
  50. For easiest and smoothest operation, the remaining files should be 
  51. installed as follows: 
  52.  
  53. ‚Ä¢ Create a folder called Mac F2C Support inside the folder within the  folder that contains the Symantec Project Manager (SPM) application.  
  54.  
  55. ‚Ä¢ Drag the two static (XCOFF) library files in the folder Mac F2C Libraries (libI77 PPC.o and libF77 PPC.o; the same ones you just built in Step 1 above) to the Mac F2C Support folder that you just created.  
  56.  
  57. WARNING:  Do not place the source code for these libraries (found in the folders libF77 Sources and libI77 Sources) in the folder containing the Symantec Project Manager application or in any of it‚Äôs sub-folders).  The source code for these libraries has name conflicts with Apple‚Äôs Universal Headers (e.g., a file called fp.h appears in both but the two are NOT equivalent files).  Otherwise any of your code that #includes any of the conflicted files may inadvertently access the wrong file.
  58.  
  59. ‚Ä¢ The folder For '(Project Models)' contains two model project folders called SPM Mac F2C C Project and SPM Mac F2C C++ Project.  Drag both folders to the (Project Models) folder located in the same folder as the SPM (if you don‚Äôt plan to use Mac F2C with the C++ compiler, you don‚Äôt need the SPM Mac F2C C++ Project folder).  
  60.  
  61.  
  62. Verifying Correct Operation of Mac F2C
  63.  
  64. The folder Test Project Δí contains the following files:
  65.  
  66. test.f -- a sample FORTRAN program.
  67.  
  68. F2Cmain.c -- the main program required to run programs produced by  Mac F2C.
  69.  
  70. F2Cmain.cp -- the main program required to run programs produced by  Mac F2C.
  71.  
  72. f2c.h -- an include file required to compile programs produced by Mac F2C.
  73.  
  74. test.c (C Output) -- what you should get when you translate the sample FORTRAN code files.
  75.  
  76. Test.PPC.œÄ -- an SPM v8.0 project to run the sample C program.
  77.   
  78. test.cp (C++ Output) -- what you should get when you translate 
  79. the sample FORTRAN code files and select the C++ output option.
  80.  
  81. Test++.PPC.œÄ -- an SPM v8.0 project to run the sample C++ program.
  82.  
  83. Test.68K.œÄ and Test++.68K.œÄ -- THINK project files to run the sample program.
  84.     
  85. Test++.*.¬µ -- CodeWarrior project files to run the sample program. 
  86.  
  87. Translate the sample FORTRAN program Test.f simply by dragging it onto Mac F2C.  Do not change any of the options (use Factory Defaults).  Once you have done this you can compare it with  Test.c (C Output) to verify that you got the same thing.  If so, double click on the SPM project Test.PPC.œÄ and run it to verify correct operation.
  88.  
  89. If you also plan to use Mac F2C C++ output with the Codewarrior, you can run a second test to verify correct operation with the C++ compiler.  Start Mac F2C and in the C Options dialog, select C++ code.  Do not change any of the other options.  Translate Test.f.  Compare it with Test.cp (C++ Output) to verify that you got the same thing.  If so, double click on the SPM project Test++.PPC.œÄ and run it to verify correct operation.
  90.  
  91.  
  92. Using C Code Generated by Mac F2C
  93.  
  94. The C code produced by Mac F2C has the following compile and link requirements when used with Symantec C/C++ for PPC:
  95.  
  96. PPC version:
  97.     ‚Ä¢ the header file:
  98.        f2c.h
  99.     ‚Ä¢ the F2C libraries: 
  100.        libI77 PPC.o 
  101.        libF77 PPC.o
  102.     ‚Ä¢ the Symantec libraries:  
  103.        PPCANSI.o
  104.        PPCunix.o 
  105.        PPCRuntime.o
  106.        InterfaceLib.xcoff
  107.        MathLib.xcoff 
  108.     ‚Ä¢ for C++ code only, the CodeWarrior library:
  109.        PPCIOStreams.o
  110.          PPCCPlusLib.o
  111.     ‚Ä¢ C++ ANSI conformance UNCHECKED (C++ only)
  112.     
  113. In addition, if you compile a stand-alone FORTRAN program (instead of only some FORTRAN subroutines) you must include F2Cmain.c in your project (or F2Cmain.cp if you use C++; the two files are identical).  This is because the original main routine in the FORTRAN program becomes a function that is called by F2Cmain.c.  In addition, F2Cmain.c performs a series of initializations (primarily related to error catching) prior to executing the main FORTRAN program.
  114.  
  115. The model project provided (SPM Mac F2C C Project) is a folder that contains everything you need to compile and run code produced by Mac F2C using the C compiler.  This folder has a copy of F2Cmain.c, f2c.h, and a project file that includes the appropriate libraries and option settings.
  116.  
  117. The C++ model project (SPM Mac F2C C++ Project) is a folder that contains everything you need to compile and run code produced by Mac F2C using the C++ compiler.  This folder has a copy of F2Cmain.cp, f2c.h, and a project file that includes the appropriate libraries and option settings.
  118.     
  119. Create a new project by using the New Project command in the Symantec Project Manager‚Äôs File menu and selecting SPM Mac F2C C Project or SPM Mac F2C C++ Project as the model for the new project.  Add your code files as appropriate, bring it up-to-date (you may need to use the Make command and the Use Disk option the first time), and run.
  120.  
  121. If you compile a FORTRAN subroutine or function that you want to call from a C program, look at the output C code to see the appropriate calling protocol.  You may or may not need to include the F2C support libraries (libF77 and libI77).  In rare cases, you may also need to copy some of the initialization code from F2Cmain.c to your calling program.
  122.  
  123. I urge all users to read the enclosed AT&T Computing Science Technical Report No. 149.  Consider it your compiler and language reference manual.  You can print the report by downloading it to any PostScript printer.  You can use Apple‚Äôs LaserWriter Utility application to do this or you can use any of the many equivalent utilities.